package bosc.cn.constant;

/**
 * @author chengcheng
 * @date 2025/9/8 21:02
 * @description 技术性错误码
 */
public enum RetCdEnum {
    SUCCESS("000000", "通信成功"),

    NETWORK_ERROR("10000", "数据库异常"),

    DATABASE_ERROR("200000", "网络异常"),
    SYSTEM_ERROR("300000", "系统异常")

    ;

    private final String code;
    private final String msg;
    RetCdEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public String getCode() {
        return code;
    }
    public String getMsg() {
        return msg;
    }
    public static String getMsgByCode(String code) {
        for (RetCdEnum value : RetCdEnum.values()) {
            if (value.code.equals(code)) {
                return value.msg;
            }
        }
        return null;
    }
    public static String getCodeByMsg(String msg) {
        for (RetCdEnum value : RetCdEnum.values()) {
            if (value.msg.equals(msg)) {
                return value.code;
            }
        }
        return null;
    }
    public static RetCdEnum getByCode(String code) {
        for (RetCdEnum value : RetCdEnum.values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }

}
